<template>
  <div class="myDiv">
    <!-- 残疾军人 -->
    <el-card class="box-card secordCard" shadow="never">
      <div slot="header" class="clearfix">
        <span>残疾军人信息</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text">收起</el-button> -->
      </div>
      <div>
        <el-form :model="form" ref="form" :rules="disabledRules" :inline="true" class="formWidth" label-width="140px">
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="伤残性质" prop="disabledProperty">
                <el-select v-model="form.disabledProperty" placeholder="请选择伤残性质">
                  <el-option
                    v-for="dict in disabledPropertyOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="伤残等级" prop="disabledLevel">
                <el-select v-model="form.disabledLevel" placeholder="请选择伤残等级">
                  <el-option
                    v-for="dict in disabledLevelOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="残疾证件号码" prop="disabledCertificateCode">
                <el-input v-model="form.disabledCertificateCode" placeholder="请输入残疾证件号码" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="评残时间" prop="evaluationDate">
                <el-date-picker clearable size="small"
                  v-model="form.evaluationDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择评残时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="孤老情况" prop="isLonely">
                <el-select v-model="form.isLonely" placeholder="请选择孤老情况">
                  <el-option
                    v-for="dict in isLonelyOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="是否因精神病评残" prop="isPsychosisDisabled">
                <el-select v-model="form.isPsychosisDisabled" placeholder="请选择是否因精神病评残">
                  <el-option
                    v-for="dict in isPsychosisDisabledOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供养情况" prop="supportSituation">
                <el-select v-model="form.supportSituation" placeholder="请选择供养情况">
                  <el-option
                    v-for="dict in supportSituationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供养单位" prop="supportUnit">
                <el-select v-model="form.supportUnit" placeholder="请选择供养单位">
                  <el-option
                    v-for="dict in supportUnitOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "disabledCard",
  data(){
    return {
       // 伤残性质字典
      disabledPropertyOptions: [],
      // 伤残等级字典
      disabledLevelOptions: [],
      // 孤老情况字典
      isLonelyOptions: [],
      // 是否因精神病评残字典
      isPsychosisDisabledOptions: [],
      // 供养情况字典
      supportSituationOptions: [],
      // 供养单位字典
      supportUnitOptions: [],
      form: {   // 残疾军人表单
      },
      disabledRules:{ // 残疾军人表单验证
        disabledProperty: [
          { required: true, message: "伤残性质不能为空", trigger: "change" }
        ],
        disabledLevel: [
          { required: true, message: "伤残等级不能为空", trigger: "change" }
        ],
        disabledCertificateCode: [
          { required: true, message: "残疾证件号码不能为空", trigger: "blur" }
        ],
      },
    }
  },
  props:{
    soldierId: String,
  },
  created(){
    this.getDicts("disability_property").then(response => {
      this.disabledPropertyOptions = response.data;
    });
    this.getDicts("disability_level").then(response => {
      this.disabledLevelOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isLonelyOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isPsychosisDisabledOptions = response.data;
    });
    this.getDicts("support_situation").then(response => {
      this.supportSituationOptions = response.data;
    });
    this.getDicts("support_unit").then(response => {
      this.supportUnitOptions = response.data;
    });
  },
  mounted(){
    this.form.soldierId = this.soldierId
  },
  methods:{
    validateForm(){
      return new Promise((resolve , reject) => {
        this.$refs.form.validate(valid => {
          if (valid) {
            resolve();
          } else reject();
        });
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.box-card{
  margin-bottom: 16px;
}
::v-deep .secordCard .el-form-item__content {
   height: 36px;
}
</style>